﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Diagnostics;
using System.Globalization;

/// <summary>
/// Summary description for WebExtensionMethods
/// </summary>
public static class WebExtensionMethods
{
    public static int AsNumber(this StateBag stateBag, string key)
    {
        Debug.Assert(stateBag != null);
        Debug.Assert(!string.IsNullOrEmpty(key));

        var value = stateBag[key];

        return value == null ? 0 : Convert.ToInt32(value, CultureInfo.InvariantCulture);
    }
}